<template>
	<view>
		<view class="container">
			<scroll-view scroll-x="true" class="tab-scroll">
				<view class="tab-scroll-box">
					<view class="tab-scroll-item">全部</view>
					<view class="tab-scroll-item" v-for="(item,index) in labelList" :class="{active: activeIndex === index }" @click="tabHightLight(item,index)" :key="item.id">{{item.name}}</view>
				</view>
			</scroll-view>
			<view class="setting-icon">
				<uni-icons class="setting" type="gear" color="#666" size="26"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "tabBar",
		props: ['labelList'],
		data() {
			return {
				activeIndex: 0
			}
		},
		methods:{
			tabHightLight(item, index) {
				this.activeIndex = index
				this.$emit('tabChange',{
					data: item,
					index: index
				})
			}
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		display: flex;
		border-bottom: 1px solid #f3f3f3;
		.tab-scroll-box {
			display: flex;
			align-items: center;
			flex-flow: nowrap row;
			height: 45px;
			.tab-scroll-item {
				text-align: center;
				flex-shrink: 0;
				font-size: 14px;
				color: #333;
				padding: 0 10px;
				&.active {
					color: tomato;
				}
			}
		}
		.setting-icon {
			flex-shrink: 0;
			height: 45px;
			width: 45px;
			display: flex;
			align-items: center;
			justify-content: center;
			position: relative;
			&::before {
				position: absolute;
				top: 12px;
				bottom: 12px;
				left: 0;
				content: '';
				width: 1px;
				background-color: #c8c8c8;
			}
		}
	}
</style>
